<form action="{:sysuri()}" method="post" data-auto="true" class="layui-form layui-card" data-table-id="DataTable">
    <div class="layui-card-body padding-left-40">

        <div class="layui-row layui-col-space15">
            <div class="layui-col-xs4 padding-bottom-0">
                <label class="relative block">
                    <span class="help-label"><b>商品名称</b>Good Title</span>
                    <input name="title" required placeholder="请输入商品名称" vali-name="商品名称" value="{$vo.title|default=''}" class="layui-input">
                </label>
            </div>
            <div class="layui-col-xs4 padding-bottom-0">
                <div class="help-label label-required-prev"><b>副标题</b>Sub Title</div>
                <label class="layui-input relative block nowrap label-required-null">
                    <input name="subtitle" required placeholder="请输入副标题" vali-name="副标题"  value="{$vo.subtitle|default=''}" class="layui-input inline-block padding-0 border-0" style="width:100%;background:none">
                </label>
            </div>
            <div class="layui-col-xs4 padding-bottom-0">
                <div class="help-label label-required-prev"><b>关键字</b>Keywords</div>
                <label class="layui-input relative block nowrap label-required-null">
                    <input name="keywords" required placeholder="请输入关键字" vali-name="关键字"  value="{$vo.keywords|default=''}" class="layui-input inline-block padding-0 border-0" style="width:100%;background:none">
                </label>
            </div>
            <div class="layui-col-xs12 padding-top-0 padding-bottom-0">
                <span class="help-block">副标题为商品名称扩充，防止商品名称过长 ~</span>
            </div>
        </div>

        <div class="layui-form-item margin-bottom-5">
            <div class="help-label"><b>商品图片</b>Goods Image</div>
            <div class="layui-textarea help-images">
                <input type="hidden" value="{$vo.thumb_url|default=''}" name="thumb_url">
            </div>
        </div>

        <div class="layui-row layui-col-space15 margin-bottom-5">
            <div class="layui-col-xs3 padding-bottom-0">
                <label class="layui-form-item margin-bottom-5 relative block">
                    <span class="help-label label-required-prev"><b>单价</span>
                    <input name="costprice" required placeholder="单价" vali-name="单价" value="{$vo.costprice|default=''}" class="layui-input">
                    <span class="help-block">供货商报价 ~</span>
                </label>
            </div>
            <div class="layui-col-xs3 padding-bottom-0">
                <label class="layui-form-item margin-bottom-5 relative block">
                    <span class="help-label label-required-prev"><b>数量</span>
                    <input name="costnum" required placeholder="数量" vali-name="数量" value="{$vo.costnum|default=''}" class="layui-input">
                    <span class="help-block">供货商报价 ~</span>
                </label>
            </div>
            <div class="layui-col-xs3 padding-bottom-0">
                <label class="layui-form-item margin-bottom-5 relative block">
                    <span class="help-label label-required-prev"><b>服务费类型</span>
                    <select name="service_fee_type">
                        <option value="1" {if isset($vo.service_fee_type) and $vo.service_fee_type == 1}selected='selected'{/if}>固定服务费</option>
                        <option value="2" {if isset($vo.service_fee_type) and $vo.service_fee_type == 2}selected='selected'{/if}>百分比服务费</option>
                    </select>
                    <span class="help-block">服务费类型 ~</span>
                </label>
            </div>
            <div class="layui-col-xs3 padding-bottom-0">
                <label class="layui-form-item margin-bottom-5 relative block">
                    <span class="help-label label-required-prev"><b>服务费</span>
                    <input name="service_fee_per" required placeholder="请输入服务费" value="{$vo.service_fee_per|default=''}" class="layui-input">
                    <span class="help-block">服务费 ~</span>
                </label>
            </div>
            <div class="layui-col-xs3 padding-top-0 padding-bottom-0">
                <label class="relative block">
                    <span class="help-label"><b>供货商</b></span>
                    <select name="merchid">
                        {foreach $merchList as $meritem}{eq name='meritem.id' value='$vo.merchid|default=0'}
                        <option selected disabled value='{$meritem.id}'>{$meritem.merchname}</option>
                        {else}
                        <option value='{$meritem.id}'>{$meritem.merchname}</option>
                        {/eq}
                        {/foreach}
                    </select>
                    <span class="help-block"></span>
                </label>
            </div>
            <div class="layui-col-xs3 padding-top-0 padding-bottom-0">
                <label class="relative block">
                    <span class="help-label"><b>分类</b></span>
                    <select name="category">
                        {foreach $categorys as $category}{eq name='category.id' value='$vo.category|default=0'}
                        <option selected value='{$category.id}'>{$category.spl}{$category.name}</option>
                        {else}
                        <option value='{$category.id}'>{$category.spl}{$category.name}</option>
                        {/eq}
                        {/foreach}
                    </select>
                    <span class="help-block"></span>
                </label>
            </div>
            <div class="layui-col-xs3 padding-top-0 padding-bottom-0">
                <label class="relative block">
                    <span class="help-label label-required-prev"><b>库存</b></span>
                    <input name="total" required placeholder="库存" vali-name="库存" value="{$vo.total|default=''}" class="layui-input">
                    <span class="help-block"></span>
                </label>
            </div>
            <div class="layui-col-xs3 padding-top-0 padding-bottom-0">
                <label class="relative block">
                    <span class="help-label label-required-prev"><b>状态</b></span>
                    <select name="status">
                        {foreach $goodsStatusList as $k=>$v}
                        {if isset($vo.status) and $vo.status eq $k}
                        <option selected disabled value='{$k}'>{$v}</option>
                        {else}
                        <option value='{$k}'>{$v}</option>
                        {/if}
                        {/foreach}
                    </select>
                    <span class="help-block"></span>
                </label>
            </div>
            <div class="layui-col-xs3 padding-top-0 padding-bottom-0">
                <label class="relative block">
                    <span class="help-label"><b>新品</b></span>
                    <br/>
                    <input type="checkbox" value="1" lay-skin="switch" name="isnew" lay-text="{:lang('是')}|{:lang('否')}" {$vo.isnew>0?'checked':''}>
                    <span class="help-block"></span>
                </label>
            </div>
            <div class="layui-col-xs3 padding-top-0 padding-bottom-0">
                <label class="relative block">
                    <span class="help-label"><b>推荐</b></span>
                    <br/>
                    <input type="checkbox" value="1" lay-skin="switch" name="isrecommand" lay-text="{:lang('是')}|{:lang('否')}" {$vo.isrecommand>0?'checked':''}>
                    <span class="help-block"></span>
                </label>
            </div>
            <div class="layui-col-xs3 padding-top-0 padding-bottom-0">
                <label class="relative block">
                    <span class="help-label"><b>热销</b></span>
                    <br/>
                    <input type="checkbox" value="1" lay-skin="switch" name="ishot" lay-text="{:lang('是')}|{:lang('否')}" {$vo.ishot>0?'checked':''}>
                    <span class="help-block"></span>
                </label>
            </div>
            <div class="layui-col-xs3 padding-top-0 padding-bottom-0">
                <label class="relative block">
                    <span class="help-label"><b>折扣</b></span>
                    <br/>
                    <input type="checkbox" value="1" lay-skin="switch" name="isdiscount" lay-text="{:lang('是')}|{:lang('否')}" {$vo.isdiscount>0?'checked':''}>
                    <span class="help-block"></span>
                </label>
            </div>
            <label class="layui-form-item block relative margin-top-10">
                <span class="help-label"><b>简介</b>Content</span>
                <textarea placeholder="简介" class="layui-textarea" name="content">{$vo.content|default=""}</textarea>
            </label>
        </div>
    </div>

    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
    <input type='hidden' value='2' name='uniacid'>
    <div class="layui-form-item text-center">
        <button class="layui-btn" type="submit">保存</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消修改吗？" data-close>取消</button>
    </div>
</form>

<script>
    $('[name=thumb_url]').uploadMultipleImage();
</script>

<script type="text/javascript">
    require(['ckeditor', 'angular'], function () {
        window.createEditor('[name="content"]', {height: 180});
    });

    layui.use('form', function(){
      var form = layui.form;
      $('input[type=checkbox]').on('click', function(e){
        $(this)[0].checked = !$(this)[0].checked;
        if($(this)[0].checked){
          $(this)[0].value = '1'
        }
        form.render('checkbox');
        });
    });
</script>